package smartcounters.androidclient;

import java.util.ArrayList;

import smartcounters.androidclient.model.UserInfo;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

public class FindUserResultsActivity extends Activity implements OnClickListener{
	public static UserInfo s_User;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.find_user_results_layout);
        
        LinearLayout layout = (LinearLayout)findViewById(R.id.findUserResultsLayout);
        
        ArrayList<UserInfo> users = FindUserActivity.s_UsersToShow;
        
        for (int i = 0; i < users.size(); i++){
        	Button button = new Button(this);
			button.setText(users.get(i).getUsername());
			button.setOnClickListener(this);
			button.setTag(users.get(i));
			layout.addView(button); 
        }
    }

	public void onClick(View v) { 
		Button button = (Button)v;
		
		s_User = (UserInfo)button.getTag();
		
		Intent intent = new Intent();
		intent.setClass(this, UserDetailsActivity.class);
		startActivity(intent);
	}
}
